package tzh;

import java.lang.reflect.Method;

public class Apptzh {
    public static void main(String[] args) throws Exception{
        User u = new User();
        u.setName("Timor");
        System.out.println(u.getName());
        Class<?> UU =Class.forName("tzh.User");
        Object o = UU.newInstance();
        Method setName = UU.getMethod("setName", String.class);
        setName.invoke(o,"Jenkins");
        Method getName = UU.getMethod("getName");
        Object result = getName.invoke(o);
        System.out.println(result);
        Method setAge = UU.getMethod("setAge", String.class);
        setAge.invoke(o,"18");
        Method getAge = UU.getMethod("getAge");
        Object result1 = getAge.invoke(o);
        System.out.println(result1);
        u.setAge("18");
        System.out.println(u.getAge());


    }
}
